package com.duck.base.oauth.security.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.duck.base.oauth.security.model.HandlerModel;
import com.duck.base.response.BaseResponse;

/**
 * 退出登录返回json
 * @author lwy
 *
 */
@Component
public class DuckLogoutSuccessHandler implements LogoutSuccessHandler {

	@Override
	public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		BaseResponse<HandlerModel> baseResp = new BaseResponse<HandlerModel>();
		HandlerModel model = new HandlerModel();
		model.setMessage("退出成功");
		baseResp.setData(model);
		response.getWriter().write(JSON.toJSONString(baseResp));
	}

}
